package com.example.shushiyunsst.fragment.main.home.child.new_sale.chlid.category

import android.os.Bundle
import android.view.View
import androidx.appcompat.widget.Toolbar
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.library_common.base.BaseFragmentEx
import com.example.shushiyunsst.R
import com.example.shushiyunsst.fragment.main.home.child.new_sale.chlid.category.bean.ClassifyMenuBean
import com.example.shushiyunsst.util.CLASSIFY

/**
 * 分类
 * */
@Route(path = CLASSIFY)
class CategoryFragment : BaseFragmentEx() {
    companion object{
        fun newInstance(): CategoryFragment {
            val args = Bundle()

            val fragment = CategoryFragment()
            fragment.arguments = args
            return fragment
        }
    }

    override fun getLayoutId()= R.layout.fen_lie_fragment

    val classifyMenu = CategoryMenuFragment.newInstance()

    val classifyContent = CategoryContentFragment.newInstance()

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        val mToolbar: Toolbar=view.findViewById(R.id.mToolbar)
        mToolbar.setTitle(R.string.goods_classify)
        mToolbar.setNavigationOnClickListener { onBackPressedSupport() }

        loadRootFragment(R.id.listMenu,classifyMenu)

        loadRootFragment(R.id.listContent,classifyContent)

        classifyMenu.setOnMenuItemClickListener(object :CategoryMenuFragment.OnMenuItemClickListener{
            override fun onItemClick(menuBean: ClassifyMenuBean) {
                classifyContent.setMenuBean(menuBean)
            }
        })
    }

    override fun onLazyInitView(savedInstanceState: Bundle?) {
        super.onLazyInitView(savedInstanceState)
//        loadRootFragment(R.id.listContent,classifyContent)
//        loadRootFragment(R.id.listMenu,classifyMenu)


    }

    override fun onBackPressedSupport(): Boolean {
        pop()
        return true
    }
}